<template>
  <div>
    <el-table :data="tableData" style="width: 100%" height="40.75rem">
      <el-table-column label="ID" width="100">
        <template slot-scope="scope">
          <i class="el-icon-lollipop"></i>
          <span style="margin-left: 10px">{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="图片" width="130">
        <template slot-scope="scope">
          <img :src="scope.row.url" alt="" />
        </template>
      </el-table-column>
      <el-table-column label="状态" width="180">
        <template slot-scope="scope">
          <i class="el-icon-user"></i>
          <span style="margin-left: 10px">{{ scope.row.status }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
          <el-button
            size="mini"
            type="success"
            @click="handleDelete(scope.$index, scope.row)"
            >添加</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { bannerData } from "@/api";
export default {
  async created() {
    let { data } = await bannerData();
    this.tableData = data.result;
  },
  data() {
    return {
      tableData: [],
    };
  },

  watch: {
    $route: {
      handler: function (val, oldVal) {
        console.log(val);
      },
      // 深度观察监听
      deep: true,
    },
  },
  methods:{
    handleEdit(a,b){
      console.log(a);
    }
  }
};
</script>

<style lang="less">
.el-table {
  /deep/.table__cell.is-leaf {
    border-bottom: 20px solid #ebeef5;
  }
  text-align: center;
  img {
    width: 9.125rem;
  }
}
</style>
